# coding=utf-8

import math
import sys
import time

def progressview(nowper):
	'''传入当前的百分比值，然后在屏幕打印输出'''
	completed = int(math.floor(nowper/2)) 
	uncompleted = 50 - completed
	
	if completed == 50:
		perStr = "  %.2f%%\n" % nowper
	else:
		perStr = "  %2.2f%%\r" % nowper
	completedStr = "=" * (completed - 1) + ">"
	uncompletedStr = "-" * uncompleted
	
	sys.stdout.write("".join(("[", completedStr, uncompletedStr, "]", perStr)))
        sys.stdout.flush()

if __name__ == "__main__":
    i = 0
    while i <= 100:
        progressview(i)
        time.sleep(0.5)
        i += 1
